<?php
    session_start();
    include "./config.php";
    $username = $_POST['username2'];
    $password = $_POST['password2'];
    $repassword = $_POST['repassword'];
	$email = $_POST['email'];
	$safecode = $_POST['safecode'];
	$Safeawser = $_POST['Safeawser'];
    mysql_select_db($main_db,$conn) or die ("Can not connect DataBase:".mysql_error());
    if(!$username || !$password || !$repassword)
    {
        echo "Please Input your UserName , PassWord and repassword";
    }
    else if($password != $repassword)
    {
        echo "PassWord not = Repassword Try Again";

    }
    else
    {
        $result = mysql_query("select * from userinfo where username = '$username'",$conn);
        $row =  mysql_fetch_array($result);
        if($row)
        {
            echo "Username alread used , Try again!";
        }
        else
        {
            mysql_query("insert into userinfo(username,password,email,safecode,safeanswer)
            values('$username','$password','$email','$safecode','$Safeawser')",$conn);
            echo "Register success";
        }

    }    
?>
